import type { AddressItem, AddressParams } from '@/types/address'
import http from '@/utils/http'

// 添加收货地址
export const postAddAddress = (data: AddressParams) => {
  return http({
    method: 'POST',
    url: `/member/address`,
    data,
  })
}

//请求获取收货地址
export const getAddress = () => {
  return http<AddressItem[]>({
    method: 'GET',
    url: `/member/address`,
  })
}
// 获取地址详情信息
export const getAddressDetail = (id: string) => {
  return http<AddressItem>({
    method: 'GET',
    url: `/member/address/${id}`,
  })
}

// 修改收货地址信息

export const putChangeAddress = (id: string, data: AddressParams) => {
  return http<AddressItem>({
    method: 'PUT',
    url: `/member/address/${id}`,
    data,
  })
}

// 删除收货地址
export const deleteAddress = (id: string) => {
  return http({
    method: 'DELETE',
    url: `/member/address/${id}`,
  })
}
